﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using GPI.Server;
using Model;
using Moon.Common;
using Moon.Common.WebInfo;

public partial class Admin_ContentManage_Sing : System.Web.UI.Page
{
    NodeService server = new NodeService();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {

                //获得查询的ID号
                string id = Request.QueryString["id"].ToString();
                this.btnSaveTemplate.CommandArgument = id;
                NodeInfo model = server.GetModel(id.ToInt(0));
                this.labTitle.Text = model.NodeName;
                if (model.Url.IsNullOrEmpty())
                {
                    model.Url = WebConfigInfo.ShowAction + model.Id;
                    new NodeService().Update(model);
                }
                //绑定内容编辑页面
                this.txtContent.Text = model.Content;

            }
            else
            {
                //this.form1.Visible = false;
                this.form1.InnerText = "404 Not Found!";
            }
        }
    }
    protected void btnSaveTemplate_Click(object sender, EventArgs e)
    {
        //获得内容编辑的ID号
        string id = this.btnSaveTemplate.CommandArgument;
        //获得编辑内容
        NodeInfo model = server.GetModel(id.ToInt(0));
        if (!model.IsHTML)
        {
            model.Url = WebConfigInfo.ShowAction + model.Id;
            model.Content = this.txtContent.Text;
            if (server.Update(model))
                MessageBox.Show(this.Page, "操作成功！");
            else
                MessageBox.Show(this.Page, "操作失敗！");
        }
        else
        { }
    }
}
